home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / source / emacs-18.59src.lha / emacs-18.59 / amiga / contrib / hessu / fakemail / fakemail.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-07-22  |  1.2 KB  |  69 lines

  1. /*
  2.  * FAKEMAIL.C
  3.  *
  4.  * compile: cc
  5.  *
  6.  * Written by Tapio Heiskanen
  7.  *
  8.  * Copyright (c) 1992 Ferry Island Technologies
  9.  * All rights reserved
  10.  *
  11.  * Created: 20-Jul-92
  12.  */
  13.  
  14. #include "version.h"
  15.  
  16. #include <proto/dos.h>
  17. #include <stdio.h>
  18. #include <stdlib.h>
  19.  
  20. char *version="$VER: fakemail V"VERSION;
  21.  
  22. void main(int ac, char **arg)
  23.     {
  24.     char buf[256], hdr[256], name[256];
  25.     FILE *fifo, *sign;
  26.     int header=1;
  27.  
  28.     sprintf(name, "T:fakemail%d", (int)name);
  29.  
  30.     if(!(fifo=fopen(name, "w")))
  31.         {
  32.         printf("FAKEMAIL: Can't open temporary file %s\n", name);
  33.         exit(10);
  34.         }
  35.  
  36. /* pipe stdin to t:<name> */
  37.  
  38.     while(fgets(buf, 256, stdin))
  39.         {
  40.         if(*buf=='\n' && header)
  41.             if(sign=fopen("uulib:.fakemailhdrs", "r"))
  42.                 {        
  43.                 while(fgets(hdr, 256, sign))
  44.                     fputs(hdr, fifo);
  45.                 fclose(sign);
  46.                 header=0;
  47.                 }
  48.         fputs(buf, fifo);
  49.         }
  50.  
  51.  
  52. /* cat uulib:.signature to t:<name> */
  53.  
  54.     if(sign=fopen("uulib:.signature", "r"))
  55.         {        
  56.         while(fgets(buf, 256, sign))
  57.             fputs(buf, fifo);
  58.         fclose(sign);
  59.         }
  60.     fclose(fifo);
  61.  
  62. /* give the file for sendmail */
  63.  
  64.     sprintf(name, "sendmail -f $user <T:fakemail%d", (int)name);
  65.     Execute(name, 0, 0);
  66.     sprintf(name, "T:fakemail%d", (int)name);
  67.     remove(name);
  68.     }
  69.